<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<style>
<!--
object {
	left:0;
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 14px;
	font: inherit;
	vertical-align: baseline;
}

.fileupload-block {
	position: relative;
	width: 100px;
	height: 100px;
	text-align: center;
	line-height: 100px;
	overflow: hidden;
	border: solid 1px #ddd;
	border-radius: 2px;
	cursor: default;	
	margin-left: auto;
	margin-right: auto;	
}

.fileupload-info {
	
}

.fileupload-file {
	font-size: 200px;
	display: inline-block;
	position: absolute;
	top: 0;
	right: 0;
	filter: alpha(opacity = 0);
	-moz-opacity: 0;
	-khtml-opacity: 0;
	opacity: 0;
	cursor: pointer;
	width: 100px;
	height: 100px;
}

.fileupload-image {
	margin:auto;
}

.fileupload-delete {
	display: inline-block;
	position: absolute;
	height: 18px;
	width:18px;
	padding: 3px;
	top: 1px;
	right: 1px;
	line-height: 18px;
	cursor: pointer;
}
.imgBtn{
	margin-left:auto;
	margin-right: auto;
}

-->
</style>
<script type="text/javascript">
  
</script>
    <div class="layui-btn-group">
        <a id="btnSave"  href="javascript:classSave();" title="保存"  class="layui-btn layui-btn-sm">
        	<i class="layui-icon">&#xe654;</i>保存
        </a>
        <a id="btnDel" ask="确定要删除吗?" itemId="${dicItem.itemId}" url="directory/deleteClass.do" title="删除"  
               href="javascript:deleteClass();" class="layui-btn layui-btn-sm">
        	<i class="layui-icon">&#xe640;</i>删除
        </a>       
    </div> 
 <fieldset>
       <legend>数据字典详情</legend>
  <form class="layui-form layui-form-pane" lay-filter="gcForm" id="gcForm" action="directory/updateDicSubClass.do" >
	  <div class="layui-form-item">
	    <label class="layui-form-label">分类名称：</label>
	    <div class="layui-input-block">
	      <input type="text" name=paramName lay-verify="paramName" value="${dicItem.paramName }" maxlength="10" autocomplete="off" placeholder="请输入分类名称" class="layui-input">
	      <input type="hidden" name="itemId" value="${ dicItem.itemId}"/>
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 父级分类：</label>
	    <div class="layui-input-inline">
	       <input type="text" name="dicName" readonly autocomplete="off" class="layui-input" value="${dic.dicName }">
	      <input type="hidden" name="dicId" value="${ dic.dicId}"/>
	    </div>
	  </div>

	
	  <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">状态:</label>
	      	<div class="layui-input-inline" >
	      	 <input type="hidden"  id="status" value="${dicItem.status}"/>
	      	  <div  style="width:150px">
	      		<select id="statu" name="status" >
  					<option value="0" >禁用</option>
  					<option value="1" >可用</option>
				</select>
			</div>
		</div>
	   </div>
	    <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">详情:</label>
		    <div class="layui-input-block">
		      <textarea name="paramValue" placeholder="请输入描述信息" rows="5" cols="100" maxLength="255" class="layui-textarea">${dicItem.paramValue }</textarea>
		    </div>
		 </div>
	</div>		  
 </form>
 </fieldset>

	<script type="text/javascript">
	layui.config({
	    base: "js/common/"
	}).use(["common", "element", "layer", "form", "table", "jquery"], function(){
			var elem = layui.element;
			var layer = layui.layer;
			var form = layui.form;
			var table = layui.table;
			var $ = layui.jquery;
			layui.common.init();		
		/**
		 删除商品分类
		**/
		window.deleteClass = function(){
		    var $this = $("#btnDel");
		    var _itemId = $this.attr("itemId");	
		    if(_itemId==""){
		       layer.msg("请在左侧选择商品分类信息后删除!", {icon: 5,time: 2000});
		      return;
		    }	    
		    layer.open({
                    icon:3,
                    title: "删除",
                    content : $this.attr("ask"),
                    btn: ['确认', '取消'],
                    yes: function(index, layero){
                        $.ajax({
                            type:"post",
                            url:$this.attr("url"),
                            data:{itemId : _itemId},
                            dataType:"json",
                            success:function(json){
                                if(json.statusCode == 200){
                                    layer.msg(json.message, {icon: 6,time: 2000});
						            $("form")[0].reset();
						            $this.attr("itemId","")
                                    var treeObj = $.fn.zTree.getZTreeObj("directory");
							        var nodes = treeObj.getSelectedNodes();
						            for (var i = 0, l = nodes.length; i < l; i++) {
						                treeObj.removeNode(nodes[i]);
						            }
                                }else{
                                    layer.msg(json.message, {icon: 5,time: 2000});
                                }
                            }
                        });
                    },
                    btn2: function(index, layero){ }
                });
        };
	
        layui.use('form', function () {
            var form = layui.form;
            $("#statu option[value="+${dicItem.status}+"]").attr('selected','selected');
            form.render('select');
        });
	
		 
     window.classSaved = function(data) {        
        if (data.statusCode == 200) {
            layer.msg(data.message, {icon: 6,time: 2000});
            var treeObj = $.fn.zTree.getZTreeObj("directoryDetails");
            var nodes = treeObj.getSelectedNodes();
            nodes[0].name = data.model.gcName;
            treeObj.updateNode(nodes[0]);
        }else{
        	layer.msg(data.message, {icon: 5,time: 2000});
        }
    }; 
    window.classSave = function() {
        var $this = $("#gcForm");
        $.post($this.attr("action"),$this.serialize(),classSaved,"json");
    };  	
});
</script>